package com.carlton.demo.conf;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;

import com.carlton.demo.entity.User;
import com.carlton.demo.service.TestService;
import com.carlton.demo.util.RedisUtil;

/**  
* <p>Title: BootRunner.java</p>  
* <p>Description: 项目启动时执行</p>   
* @author Carlton  
* @date 2018年10月8日 下午5:44:26
*/
//注释掉 Component 使该方法失效
//@Component
public class BootRunner implements CommandLineRunner {

	@Autowired
	TestService testService;
	@Autowired
	RedisUtil redisUtil;

	@Override
	public void run(String... args) throws Exception {
		System.out.println("This will be execute when the project was started!");

		System.out.println("=============================测试cache2=============================");
		testService.testPrint();
		int id = 35;
		User user = testService.gener(id, "uu", 44);
//		String name= testService.gener2(33);
		System.out.println("-------------" + user.getId() + "-------------");
//		System.out.println("-------------" + name + "-------------");

		Object object = redisUtil.hget("userr", id + "");
		if (object == null) {
			System.out.println("null");
		}
		Object object1 = redisUtil.lGetIndex("userr", id);
		if (object1 == null) {
			System.out.println("null 1");
		}
		Object object2 = redisUtil.get("userr::" + id);
		if (object2 == null) {
			System.out.println("null 2");
		}

		System.out.println("++++++++++");

	}

}
